syntax = "proto3";

package nighthawk;

import "google/rpc/status.proto";

import "envoy/config/core/v3/address.proto";

import "api/client/service.proto";

import "validate/validate.proto";

// Perform an execution request through an intermediate service that will in turn delegate to one or
// more other services Nighthawk load generator services.
message DistributedRequest {
  client.ExecutionRequest execution_request = 1;
  // Specify one or more services that will handle the inner message associated to this.
  repeated envoy.config.core.v3.Address services = 3 [(validate.rules).repeated .min_items = 1];
}

message DistributedServiceResponse {
  oneof distributed_response_type {
    google.rpc.Status error = 1;
    nighthawk.client.ExecutionResponse execution_response = 2;
  }
  // The service that is associated to this fragment.
  envoy.config.core.v3.Address service = 3;
}

// Carries responses associated with a DistributedRequest.
message DistributedResponse {
  repeated DistributedServiceResponse service_response = 1;
}

// Service which distributes messages to one or more other services for handling, and streams back
// response messages.
service NighthawkDistributor {
  // Propagate the message wrapped in DistributedRequest to one or more other services for handling.
  rpc DistributedRequestStream(stream DistributedRequest) returns (stream DistributedResponse) {
  }
}
